package com.slixils.demo.validator;

import com.slixils.demo.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @Author: JinChongLi
 * @Description:校验密码
 * @Date: Created in 1:26 2022/4/8
 * @Modified By:
 */
public class IsPassWordCheck implements ConstraintValidator<IsPassWord,String> {
  private String message ;

    @Autowired
    UserMapper userMapper;
    @Autowired
    IsMobileValidator isMobileValidator;
    @Override
    public void initialize(IsPassWord constraintAnnotation) {
        message = constraintAnnotation.message();
    }

    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
//                String s1 = MD5Util.inputPassToDbPass(s, MD5Util.salt);
//        System.out.println(">>>>>>>>>>>>>>>>>");
//                User user = userMapper.selectById(isMobileValidator.valid);
//        boolean equals = user.getPassword().equals(s1);
//        if(!equals){
//            throw new GlobalException(RespBeanEnum.LOGIN_ERROR);
//        }
//        return equals;
      return true;
    }
}
